<template>
  <div>
    <FilterTable
      ref="table"
      :columns="columns"
      columnsRef="partPartOtherRepairPartBuyInvoicDetail"
      :dataSource="dataSource"
      :isSelectColumn="false"
      :isMemoryPagination="true"
      :onColumnsChange="columns => (this.columns = columns)"
    >
    </FilterTable>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'center'
      }"
    >
      <el-button @click="closeDialog(true)">关 闭</el-button>
    </div>
  </div>
</template>

<script>
/**
 * @Author: 刘加明
 **/
import moment from 'moment';
import { mapState } from 'vuex';
import { dictionary } from '@/utils/dictMixin';
import { getInvoiceItemX } from '@/api/part/partOther/repairPartBuyInvoic';

export default {
  name: 'Detail',
  mixins: [dictionary],
  props: ['authId'],
  data() {
    return {
      columns: this.createTableColumns(),
      dataSource: []
    };
  },
  computed: {},
  mounted() {
    this.createBaseTable();
    this.getInvoiceItemX(this.authId);
  },
  methods: {
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '采购单号',
          dataIndex: 'purchaseCode',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '配件代码',
          dataIndex: 'partNo',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '配件名称',
          dataIndex: 'partName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '认证数量',
          dataIndex: 'qty',
          summation: true,
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '认证金额',
          dataIndex: 'amt',
          summation: true,
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '认证税额',
          dataIndex: 'tax',
          summation: true,
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '认证不含税金额',
          dataIndex: 'costAmt',
          summation: true,
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '未认证数量',
          dataIndex: 'unQty',
          summation: true,
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '未认证金额',
          dataIndex: 'unAmount',
          summation: true,
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '未认证税额',
          dataIndex: 'unTax',
          summation: true,
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '未认证不含税金额',
          dataIndex: 'unCostAm',
          summation: true,
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '数量',
          dataIndex: 'inQuantity',
          summation: true,
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '金额',
          dataIndex: 'inAmTax',
          summation: true,
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '税额',
          dataIndex: 'taxAmount',
          summation: true,
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '不含税金额',
          dataIndex: 'inAmount',
          summation: true,
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '采购单价',
          dataIndex: 'inPriceTax',
          sorter: true,
          precision: 2,
          filter: true,
          filterType: 'number'
        },
        {
          title: '采购税率',
          dataIndex: 'taxs',
          sorter: true,
          precision: 2,
          filter: true,
          filterType: 'number'
        },
        {
          title: '仓库代码',
          dataIndex: 'storageCode',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '仓库名称',
          dataIndex: 'storageName',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    },
    // 声明表格组件
    createBaseTable() {
      this.BaseTable = this.$refs.table.$refs.pageTable;
    },
    closeDialog(val) {
      this.$emit('close', val);
    },
    async getInvoiceItemX(authId) {
      const res = await getInvoiceItemX(authId);
      // console.log(res)
      if (res.resultCode == 200) {
        this.dataSource = res.data;
        // this.BaseTable.dataSource = res.data
        // this.$nextTick(()=>{
        //   console.log(this.BaseTable.originData, 'originData')
        // })
      }
    }
  }
};
</script>

<style lang="less" scoped></style>
